﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;

public partial class yaopincha : System.Web.UI.Page
{
    private static string sqlconn = System.Configuration.ConfigurationManager.AppSettings["sqlcon"].ToString().Trim();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnsearch_Click(object sender, EventArgs e)
    {
        string m = txtm.Text.Trim();
        users us = new users();
        us.id = m;
        int result = us.chayao(us);
        if (result != 0)
        {
            SqlDataReader rd = us.getallyao(us);
            while (rd.Read())
            {

                txtspm.Text = rd["Y_NAME"].ToString(); ;
                txtspbh.Text = rd["Y_ID"].ToString(); ;
                txtspwqy.Text = rd["Y_GUIGE"].ToString();
                txtspnqy.Text = rd["Y_PLACE"].ToString();
                txtspnsl.Text = rd["Y_FUNCTION"].ToString();
                txtspwsl.Text = rd["Y_GNAME"].ToString();

                txtsplb.Text = rd["Y_TYPE"].ToString();




            }
        }
        else
        {
            lblts.Visible = true;
            lblts.Text = "此药品不存在！";
        }
    }
    protected void btnxg_Click(object sender, EventArgs e)
    {
        if (txtspbh.Text != "")
        {
            users us = new users();
            us.name = txtspm.Text.Trim();
            us.id = txtspbh.Text.Trim();
            us.guige = txtspwqy.Text.Trim();
            us.place = txtspnqy.Text.Trim();
            us.fun = txtspnsl.Text.Trim();
            us.gname = txtspwsl.Text.Trim();

            us.type = txtsplb.Text.Trim();


            int result = us.Updayaopin(us);
            if (result != 0)
            {
                lblts.Visible = true;
                lblts.Text = "修改成功！";
            }
            else
            {
                lblts.Visible = true;
                lblts.Text = "修改失败！";
            }
        }
        else
        {
            lblts.Visible = true;
            lblts.Text = "请先查询药品！";
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string id = txtspbh.Text.Trim();
        string name = txtspm.Text.Trim();
        users us = new users();
        us.id = id;
        us.name = name;

        int result = us.Deleteyaopin(us);
        lblbb.Visible = true;
        lblbb.Text = "删除成功！";
               
    }
}